package com.sky.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.mapper.DishMapper;
import com.sky.result.PageResult;
import com.sky.service.DishService;
import com.sky.vo.DishVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DishServiceImpl implements DishService {
    @Autowired
    private DishMapper dishMapper;

    // 分页查询
    @Override
    public PageResult pageQuery(DishPageQueryDTO dishPageQueryDTO) {
        PageHelper.startPage(dishPageQueryDTO.getPage(),dishPageQueryDTO.getPageSize());
        Page<Dish> pageInfo = dishMapper.pageQuery(dishPageQueryDTO);
        return new PageResult(pageInfo.getTotal(),pageInfo.getResult());
    }

    //按id查询
    @Override
    public DishVO getById(Long id) {
        return dishMapper.getById(id);
    }
    // 修改
    @Override
    public void update(DishDTO dishDTO) {
        //属性拷贝
        Dish dish = new Dish();
        dish.setId(dishDTO.getId());


    }
}
